package com.oude.dndclub.utils;

import android.content.SharedPreferences;

public class PreferenceUtils {

    public static void setFloat(String key, float value) {
        SharedPreferences.Editor editor = PublicStaticData.mySharedPreferences.edit();
        editor.putFloat(key, value);
        editor.commit();
    }

    public static Float getFloat(String key, float devalue) {
        return PublicStaticData.mySharedPreferences.getFloat(key, devalue);
    }

    // 存String
    public static void setString(String key, String value) {
        SharedPreferences.Editor editor = PublicStaticData.mySharedPreferences.edit();
        editor.putString(key, value);
        editor.commit();
    }

    //取String
    public static String getString(String key, String devalue) {
        return PublicStaticData.mySharedPreferences.getString(key, devalue);
    }

    //取boolean
    public static boolean getBoolean(String key, boolean defValue) {
        return PublicStaticData.mySharedPreferences.getBoolean(key, defValue);
    }

    //存boolean
    public static void setBoolean(String key, boolean value) {
        SharedPreferences.Editor editor = PublicStaticData.mySharedPreferences.edit();
        editor.putBoolean(key, value);
        editor.commit();
    }

    //取int
    public static int getInt(String key, int defValue) {
        return PublicStaticData.mySharedPreferences.getInt(key, defValue);
    }

    // 存int
    public static void setInt(String key, int value) {
        SharedPreferences.Editor editor = PublicStaticData.mySharedPreferences.edit();
        editor.putInt(key, value);
        editor.commit();
    }

    //清空一个
    public static void remove(String key) {
        SharedPreferences.Editor editor = PublicStaticData.mySharedPreferences.edit();
        editor.remove(key);
        editor.commit();
    }

    //清空所有
    public static void removeAll() {
        SharedPreferences.Editor editor = PublicStaticData.mySharedPreferences.edit();
        editor.clear();
        editor.commit();
    }
}
